﻿@model IEnumerable<Common.Views.OrdersView>

@{
    ViewBag.Title = "Manage Returns/Faults";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Manage Returns/Faults</h2>

@if (Model.Count() > 0)
{
<table>
    <tr>
        <th>Product Name</th>
        <th>Product Image</th>
        <th>Price</th>
        <th>Warranty Expiry Date</th>
        <th>Report a Fault</th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.ProductName)
        </td>
        <td>
            <img height="150px" width="150px" src= "@Url.Content(item.ImageLink)" alt="@Html.DisplayFor(modelItem => item.ImageLink)" />
        </td>
        <td>
            €@Html.DisplayFor(modelItem => item.UnitPrice)
        </td>
        <td>
            @if (item.WarrantyExpiryDate > DateTime.Now)
            {
                @Html.DisplayFor(modelItem => item.WarrantyExpiryDate)
            }
            else
            {
                <div style="color:Red">
                    @Html.Label("Warranty has expired!")
                </div>
            }
        </td>
        <td>
            @Html.ActionLink("Generate Ticket Number", "FaultDetails", new { pId = item.ProductID, oId = item.OrderID })
        </td>
    </tr>
}
</table>
}
else
{
    <div style="color: Red">No products were found</div>
}
